<%@ page pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8"> 	
<link rel="stylesheet" type="text/css" media="all"
	href="<c:url value='/styles/tree.css'/>" />
	<link href="./styles/layout.css" rel="stylesheet" type="text/css" />	
<SCRIPT language=JavaScript src="<c:url value='/scripts/style.js'/>"></SCRIPT>
<SCRIPT language=JavaScript src="<c:url value='/scripts/function_help.js'/>"></SCRIPT>
<SCRIPT language=JavaScript src="<c:url value='/scripts/common.js'/>"></SCRIPT>
<SCRIPT>
function killErrors() {
return true;
}
window.onerror = killErrors;

foldersTree = gFld("-1","<bean:message key="dept.common.title.label"/>","",1);    
<% 
	String target = request.getParameter("target");
	java.util.ArrayList deptList = (java.util.ArrayList)request.getAttribute("deptList"); 
	StringBuffer str = new StringBuffer("");
	com.sasis.model.DeptInfo deptInfo = null;
	for(int i=0;i<deptList.size();i++){ 
		deptInfo = (com.sasis.model.DeptInfo) deptList.get(i);
		String aa = "";
		if(0==deptInfo.getParentId()){
			if(deptInfo.getLeaf()){
			 	if("-1".equals(target)){
					aa ="\n insDoc(foldersTree,gLnk("+target+
						",\""+deptInfo.getName()+"\",\"setTree("+deptInfo.getId()+
						",'"+deptInfo.getName()+"')\",1));\n";
			 	}else {
			 	      aa ="\n insDoc(foldersTree,gLnk("+target+
						",\""+deptInfo.getName()+"\",\"setTree("+deptInfo.getId()+",'"+deptInfo.getName()+"')\",1));\n";
				}		
			}else 	{
				if("-1".equals(target)){
					aa = "s"+deptInfo.getId() +"= insFld(foldersTree,gFld(\""+deptInfo.getId()+"\",\""+deptInfo.getName()+"\",\"\",\"\",-1));\n";	
				}else {
					aa = "s"+deptInfo.getId() +"= insFld(foldersTree,gFld(\""+deptInfo.getId()+"\",\""+deptInfo.getName()+"\",\"\",\"\",1));\n";	
				}
			}	
			str.append(aa);
		}else{ 
			if(deptInfo.getLeaf()){
				if("-1".equals(target)){
					aa="\n insDoc("+"s"+deptInfo.getParentId()+",gLnk(-1,\""+deptInfo.getName()+"\",\"setTree("+deptInfo.getId()+",'"+deptInfo.getName()+"')\",1));\n";
				}else{
					aa="\n insDoc("+"s"+deptInfo.getParentId()+",gLnk(1,\""+deptInfo.getName()+"\",\"setTree("+deptInfo.getId()+",'"+deptInfo.getName()+"')\",1));\n";
				}		
			}else {
				if("-1".equals(target)){
					aa = "s"+deptInfo.getId() +"= insFld("+"s"+deptInfo.getParentId()+",gFld(\""+deptInfo.getId()+"\",\""+deptInfo.getName()+"\",\"\",\"\",-1));\n";
				}else {
					aa = "s"+deptInfo.getId() +"= insFld("+"s"+deptInfo.getParentId()+",gFld(\""+deptInfo.getId()+"\",\""+deptInfo.getName()+"\",\"\",\"\",1));\n";
				}	
			}	
				

			str.append(aa);
		}
	}  
%> 
	
<%=str.toString() %> 
</SCRIPT>
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
</HEAD>
<BODY  style="MARGIN-LEFT: 5px; MARGIN-RIGHT: 10px;border-right:1px solid gray " style="background-color: #F3F3F3;">
<TABLE cellSpacing=0 cellPadding=0 width="95%" align=center border=0 style="border-collapse:collapse;" height="90%">
  <TBODY>
  <TR>
    <TD align="left" valign="top" >
      <TABLE  cellSpacing=0 cellPadding=0  border=0 width=100%>
        <TBODY>
        <TR>
          <TD>
            <SCRIPT>initializeDocument()</SCRIPT>
          </TD>
		  </TR>
		  </TBODY>
	  </TABLE>
	</TD>
  </TR>
 </TBODY>
</TABLE>

</BODY>
<script>
	function setTree(id,title){	 
		var stitle = parent.document.all('title');
		stitle.value = title;
		outPut(id,title);
	}
	
	function outPut(id,title){  
		var textObj = parent.opener.document.getElementById('selectedText'); 
		var idObj = parent.opener.document.getElementById('selectedId'); 

		if(null!=textObj ){
			textObj.value = title;
		}
  
		if(null!= idObj){
			idObj.value = id;	
		}
				// alert(idObj.value);
	}
	//deptInfoAction.html?method=
</script>
</HTML>
